#include <stdio.h>
#include <math.h>

void caipan()
{
    double scores[10];
    double min = 0, max = 0;
    int max_index = 0, min_index = 0;
    double sum = 0;
    printf("请输入10个评委的评分(范围0到100,结果自动保留两位小数):\n");
    for (int i = 0; i < 10;)
    {
        double input;
        printf("评委 %d:", i + 1);

        if (scanf("%lf", &input) == 1 && input >= 0 && input <= 100)
        {

            scores[i++] = input;
            sum += input;
            if (input > max)
                max_index = i, max = input;
            if (input < min)
                min_index = i, min = input;
        }
        else
            printf("错误,请重输\n");
    }

    double average = sum / 8.00;
    printf("选手得分:%.2f\n", average);

    double minw = 100, maxw = 0;

    for (int i = 0; i < 10; i++)
    {
        double w = fabs(scores[i] - average);
        if (w <= minw)
        {
            minw = w;
            min = i;
        }
        if (w > maxw)
        {
            maxw = w;
            max = i;
        }
    }
    printf("评委%d最公平，评委%d最不公平\n", min + 1, max + 1);
}
void er()
{
    int s = 0;
    char i;
    printf("请将二进制数从右往左输入(输入#结束)\n");

    while (i != '#')
    {
        i = getchar();
        switch (s)
        {
        case 0:
            if (i == 'o')
                s = 0;
            else if (i == '1')
                s = 1;
            break;
        case 1:
            if (i == '1')
                s = 3;
            else if (i == '0')
                s = 2;
            break;
        case 2:
            if (i == '1')
                s = 0;
            else if (i == '0')
                s = 4;
            break;
        case 3:
            if (i == '0')
                s = 1;
            else if (i == '1')
                s = 2;
            break;
        case 4:
            if (i == '1')
                s = 4;
            else if (i == '0')
                s = 3;
            break;
        }
    }
    if (s = 0)
        printf("可以被5整除\n");
    else
        printf("不能被5整除\n");
}
void zimo()
{
    char m[999];
    int s[26] = {0};
    printf("请输入一个字符串（全部小写字母，输入#结束）: ");
    fgets(m, sizeof(m), stdin);
    for (int i = 0; m[i] != '#'; i++)
    {
        if (m[i] >= 'a' && m[i] <= 'z')
            s[m[i] - 'a']++;
    }
    for (int i = 0; i < 26; i++)
    {
        if (s[i] > 0)
            printf("%c: %d\n", 'a' + i, s[i]);
    }
}
int main()
{
    printf("菜单\n");
    printf("1 最公平最不公平评委\n");
    printf("2 能被5整除的数\n");
    printf("3 统计字符数\n");
    printf("0 退出\n请输入\n");
    int n;
    scanf("%d", &n);
    switch (n)
    {
    case 0:
        printf("结束");
        break;
    case 1:
        caipan();
        break;
    case 2:
        er();
        break;
    case 3:
        zimo();
        break;
    }
    return 0;
}